﻿using System;
using Sinacor.Infra.UI.Common;
using Sinacor.Infra.UI.Security.Services;
using Sinacor.UI.Bovespa.Monitoracao.Communication.Bovespa.Parametro.ConfiguracaoOMM;

namespace Sinacor.UI.Bovespa.Monitoracao.Communication
{
    public class Configuracao : BaseCommunication
    {

        #region Construtores
        /// <summary>
        /// Construtor parametrizado
        /// </summary>
        /// <param name="sessionInformation"></param>
        public Configuracao(SessionInformation sessionInformation)
            : base(sessionInformation)
        {
        }

        #endregion Construtores

        #region Métodos

        public Model.MonitorOMMConfiguracao ObterMonitorOMMConfiguracaoCliente()
        {
            Model.MonitorOMMConfiguracao response = new Sinacor.UI.Bovespa.Monitoracao.Model.MonitorOMMConfiguracao();

            IConfiguracaoOMM servico = null;
            try
            {
                using (ServiceInstance<IConfiguracaoOMM> service = new ServiceInstance<IConfiguracaoOMM>())
                {
                    servico = service.TryGetInstance(this.Session);
                    response = new Translator.DataContractToModel.MonitorOMMConfiguracao().ToMonitorOMMConfiguracao(
                                        servico.ObterMonitorOMMConfiguracaoCliente());
                }
            }
            catch (Exception ex)
            {
                base.HandleFault(ex);
            }

            return response;
        }

        #endregion Métodos

    }
}
